package Maps 
{
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;
	
	/**
	 * ...
	 * @author Serg de Adelantado
	 */
	public class TooltipHeader extends Sprite 
	{
		private var FColor:uint;
		private var FValue:TextField;
		private var FFormat:TextFormat;
		private var FWidth:Number;
		
		public function TooltipHeader(AWidth:int, AColor:uint, ATextColor:uint) 
		{
			FColor = AColor;
			FValue = new TextField();
			FFormat = new TextFormat('Calibri', 14, ATextColor);
			FFormat.align = TextFormatAlign.CENTER;
			FValue.defaultTextFormat = FFormat;
			FValue.text = '-';
			FValue.width = AWidth;
			FValue.height = FValue.textHeight + 4;
			Width = AWidth;
			addChild(FValue);
			mouseEnabled = mouseChildren = false;
		}
		
		private function Redraw():void
		{
			graphics.clear();
			graphics.beginFill(FColor)
			graphics.lineTo(FWidth, 0);
			graphics.lineTo(FWidth, FValue.height);
			graphics.lineTo(0, FValue.height);
			graphics.lineTo(0, 0);	
		}
		
		public function set Width(AWidth:Number):void 
		{
			FWidth = AWidth;
			FValue.width = AWidth;
			Redraw();
		}
		
		public function set Color(AColor:uint):void 
		{
			if (FColor != AColor)
			{
				FColor = AColor;
				Redraw();
			}
		}	
		
		public function set Value(AValue:String):void 
		{
			FValue.text = AValue;			
		}
	}
}